
import numpy as np
import pandas as pd

arr1 = np.array([
    [
        ['a', 'b'],
        ['c', 'd']
    ],
    [
        ['e', 'f'],
        ['g', 'h']
    ]
])
arr2 = np.rollaxis(arr1, 2, 1)
print(arr2)

data = {
    'name': ['张三', '李四', '王五'],
    'sex': ['男', '女', '男'],
    'age': [18, 20, 19]
}
df = pd.DataFrame(data, index=[1001, 1002, 1003])
df.loc[1004] = ['赵瑶', '女', 18]
df.loc[1005] = ['钱瑶', '男', 19]
# print(df)
df.to_excel('student.xlsx', sheet_name='stu')


def find_name(stus):

    # 访问stu行
    name_age = {}
    for index, row in stus.iterrows():
        if row['name'].rfind('瑶') != -1:
            name_age[row['name']] = row['age']
    return name_age


stus = pd.read_excel('student.xlsx', sheet_name='stu', index_col=0)
print(find_name(stus))


